<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\config;
use Illuminate\Http\Request;
use App\Models\UserInfo;
use App\Models\User;


class AliPayController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $users = auth()->user()->user_info()->first();


        return view('user.pay.alipay',compact('users'));
    }


    /**
     * 添加 用户信息数据
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request , UserInfo $userInfo)
    {
        $userInfo->fill($request->all());
        $userInfo->user_id = auth()->id();

        if ($userInfo->save()){
            return response()->json([
                'code'=> 1,
                'msg' => '添加成功',
            ]);
        }else{
            return response()->json([
                'code'=> 0,
                'msg' => '添加失败',
            ]);
        }
    }


    // 修改用户信息数据
    public function update(Request $request , UserInfo $alipay){

        $alipay->fill($request->all());

        if ($alipay->update()){
            return response()->json([
                'code'=> 1,
                'msg' => '修改成功',
            ]);
        }else{
            return response()->json([
                'code'=> 0,
                'msg' => '修改失败',
            ]);
        }
    }


    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function wecha_index()
    {
        $users = auth()->user()->user_info()->first();

        return view('user.pay.wechapay',compact('users'));
    }


}
